package com.tanhua.server.service;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.dubbo.server.api.RecommendUserApi;
import com.tanhua.dubbo.server.pojo.RecommendUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class RecommendService {

    @Reference
    private RecommendUserApi recommendUserApi;

    @Autowired
    private BlackUserService blackUserService;

    //查询今日佳人
    public RecommendUser findByUid(Long id) {
        return recommendUserApi.findBytoUserId(id);
    }

    //查询推荐好友
    public List<RecommendUser> findAllByUid(Long id, Integer page, Integer pageSize) {
        //查询黑名单用户id
        List<Long> longs = blackUserService.queryAllBlackUser();
        return recommendUserApi.findAllByUid(id, longs,page, pageSize);
    }

    //查询推荐好友的缘分值
    public Double queryScore(Long userId, Long toUserId){
        Double score = this.recommendUserApi.queryScore(userId, toUserId);
        if(ObjectUtil.isNotEmpty(score)){
            return score;
        }
        //默认值
        return 98d;
    }

    public List<RecommendUser> queryCardList(Long id, Integer count,List<Long> blackUsers) {
        return recommendUserApi.queryCardList(id, count,blackUsers);
    }
}
